#ifndef _BSP_DEBUG_USART_H
#define	_BSP_DEBUG_USART_H

#include "stm32f10x.h"
#include <stdio.h>
#include "FreeRTOS.h"
#include "semphr.h"
#include "lwrb.h"

#define  DEBUG_USART                    USART2
#define  DEBUG_USART_CLK                RCC_APB1Periph_USART2
#define  DEBUG_USART_APBxClkCmd         RCC_APB1PeriphClockCmd
#define  DEBUG_USART_BAUDRATE           115200

#define  DEBUG_USART_GPIO_CLK           (RCC_APB2Periph_GPIOA)
#define  DEBUG_USART_GPIO_APBxClkCmd    RCC_APB2PeriphClockCmd
    
#define  DEBUG_USART_TX_GPIO_PORT       GPIOA   
#define  DEBUG_USART_TX_GPIO_PIN        GPIO_Pin_2
#define  DEBUG_USART_RX_GPIO_PORT       GPIOA
#define  DEBUG_USART_RX_GPIO_PIN        GPIO_Pin_3

#define  DEBUG_USART_RX_DMA_CHANNEL     DMA1_Channel6
#define  DEBUG_USART_TX_DMA_CHANNEL     DMA1_Channel7
#define  DEBUG_USART_DR_ADDRESS        (&DEBUG_USART->DR)

#define  DEBUG_USART_RX_DMA_BUFF_SIZE          256    
#define  DEBUG_USART_TX_RINGBUFF_SIZE          1024
#define  DEBUG_USART_RX_RINGBUFF_SIZE          256

#define ARRAY_LEN(x)            (sizeof(x) / sizeof((x)[0]))

extern SemaphoreHandle_t debug_usart_rx_sem;
extern lwrb_t debug_usart_rx_dma_ringbuff;  
extern lwrb_t debug_usart_tx_dma_ringbuff; 

extern void DEBUG_USART_Config(void);
extern void debug_usart_send_data(uint8_t *data,size_t len);

#endif
